﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Daco.Web.Masters
{
    public class PUBLISHMaster : DACOMaster
    {
        public PUBLISHMaster()
        {
            this.Load += new EventHandler(PUBLISHMaster_Load);
        }

        void PUBLISHMaster_Load(object sender, EventArgs e)
        {
            // get the current page...
            string pageSrc = GetPageSource();

            try
            {
                #region "Bind PUBLISH Template"
                #endregion

                Daco.Web.UI.SitePage currentPage = (Daco.Web.UI.SitePage)Page.LoadControl(pageSrc);

                CurrentPage = currentPage;
                CurrentPage.Master = this;
                CurrentPage.Header = Header;
                CurrentPage.Footer = Footer;
                CurrentPage.Navigator = Navigator;

                Body.Right.Controls.Add(CurrentPage);

                CPageContext.Current.CurrentPage = CurrentPage;

                // add the header control before the page rendering...
                Controls.AddAt(0, Header);
                Controls.AddAt(1, Navigator);
                // add the page before the page rendering...
                Controls.Add(Body);
                // add the footer control after the page...
                Controls.Add(Footer);
            }
            catch (System.IO.FileNotFoundException)
            {
                // Phat sinh application exception, thong bao tai nguyen truy xuat khong ton tai hoac khong co tham quyen
                throw new ApplicationException(Daco.Web.Resources.DACO.ResourceNotFound);
            }
        }
    }
}
